home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / wnos5src.zip / MBUF.H < prev    next >
Text File  |  1993-08-09  |  2KB  |  63 lines

  1. #ifndef    _MBUF_H
  2. #define _MBUF_H
  3.  
  4. #if !defined(__STDIO_DEF_) && !defined(__STDIO_H)
  5. #  include <stdio.h>
  6. #endif
  7.  
  8. #ifndef _GLOBAL_H
  9. #include "global.h"
  10. #endif
  11.  
  12. /* Basic message buffer structure */
  13. struct mbuf {
  14.     struct mbuf *next;    /* Links mbufs belonging to single packets */
  15.     struct mbuf *anext;    /* Links packets on queues */
  16.     int16 size;        /* Size of associated data buffer */
  17.     int refcnt;        /* Reference count */
  18.     struct mbuf *dup;    /* Pointer to duplicated mbuf */
  19.     char *data;        /* Active working pointers */
  20.     int16 cnt;
  21. };
  22. #define    NULLBUF    (struct mbuf *)0
  23. #define    NULLBUFP (struct mbuf **)0
  24.  
  25. #define    PULLCHAR(bpp)\
  26.  ((bpp) != NULL && (*bpp) != NULLBUF && (*bpp)->cnt > 1 ? \
  27.  ((*bpp)->cnt--,(unsigned char)*(*bpp)->data++) : pullchar(bpp))
  28.  
  29. void enqueue __ARGS((struct mbuf **q,struct mbuf *bp));
  30. void append __ARGS((struct mbuf **bph,struct mbuf *bp));
  31. void free_q __ARGS((struct mbuf **q));
  32. void trim_mbuf __ARGS((struct mbuf **bpp,int16 length));
  33. struct mbuf *alloc_mbuf __ARGS((int16 size));
  34. struct mbuf *free_mbuf __ARGS((struct mbuf *bp));
  35. struct mbuf *dequeue __ARGS((struct mbuf **q));
  36. struct mbuf *copy_p __ARGS((struct mbuf *bp,int16 cnt));
  37. struct mbuf *free_p __ARGS((struct mbuf *bp));
  38. struct mbuf *qdata __ARGS((char *data,int16 cnt));
  39. struct mbuf *pushdown __ARGS((struct mbuf *bp,int16 size));
  40. int16 pullup __ARGS((struct mbuf **bph,char *buf,int16 cnt));
  41. int16 dup_p __ARGS((struct mbuf **hp,struct mbuf *bp,int16 offset,int16 cnt));
  42. int16 len_p __ARGS((struct mbuf *bp));
  43. int16 dqdata __ARGS((struct mbuf *bp,char *buf,unsigned cnt));
  44. int16 len_q __ARGS((struct mbuf *bp));
  45. int32 pull32 __ARGS((struct mbuf **bpp));
  46. int32 get32 __ARGS((char *cp));
  47. int16 pull16 __ARGS((struct mbuf **bpp));
  48. void refiq __ARGS((void));
  49. void mbuf_crunch __ARGS((struct mbuf **bpp));
  50. int16 get16 __ARGS((char *cp));
  51. int pullchar __ARGS((struct mbuf **bpp));
  52. char *put16 __ARGS((char *cp,int16 x));
  53. char *put32 __ARGS((char *cp,int32 x));
  54. int write_p __ARGS((FILE *fp,struct mbuf *bp));
  55. void iqstat __ARGS((void));
  56.  
  57. #define    AUDIT(bp)    audit(bp,__FILE__,__LINE__)
  58.  
  59.  
  60. #endif    /* MBUF_H */
  61.  
  62.  
  63.